package cn.tedu.spring;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class SpringRunner {
    public static void main(String[] args) {
        //1.加载Spring
        System.out.println("1.加载Spring开始");
        AnnotationConfigApplicationContext ac
                = new AnnotationConfigApplicationContext(SpringConfig.class);
        System.out.println("1.加载Spring结束");

        //2.从Spring中获取对象
        System.out.println("2.从Spring中获取对象,开始");
        UserMapper userMapper1 = ac.getBean("userMapper",UserMapper.class);
        System.out.println("2.从Spring中获取对象,结束");

        //3.测试使用对象,以便于观察是否获取到了有效的对象
        System.out.println("3.测试开始");
        System.out.println(userMapper1);
        System.out.println("3.测试结束");

        //4.关闭
        System.out.println("4.关闭");
        ac.close();
    }
}
